package com.tjmc.recruit.user.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tjmc.company.api.entity.JobInfoEntity;
import com.tjmc.recruit.common.core.exception.CheckedException;
import com.tjmc.recruit.user.entity.PersonalCollectLogEntity;
import com.tjmc.recruit.user.mapper.PersonalCollectLogMapper;
import com.tjmc.recruit.user.service.PersonalCollectLogService;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * 个人收藏表
 *
 * @author recruit
 * @date 2024-11-11 17:21:06
 */
@Service
public class PersonalCollectLogServiceImpl extends ServiceImpl<PersonalCollectLogMapper, PersonalCollectLogEntity> implements PersonalCollectLogService {

    @Override
    public Page<JobInfoEntity> getCollectPage(Page page, PersonalCollectLogEntity personalCollectLog) {
        Map<String, Object> params = new HashMap<String, Object>();
        if (personalCollectLog.getAccountId() == null) {
            throw new CheckedException("用户ID不能为空");
        }
        params.put("accountId", personalCollectLog.getAccountId());
        if (StrUtil.isNotBlank(personalCollectLog.getJobId())) {
            params.put("jobId", personalCollectLog.getJobId());
        }
        Page<PersonalCollectLogEntity> personalCollectLogEntityPage = new Page<>(page.getCurrent(), page.getSize());
        return baseMapper.getCollectPage(personalCollectLogEntityPage, params);
    }
}
